<?php
//链接swoole tcp 服务

$client = new swoole_client(SWOOLE_SOCK_TCP);

if (!$client->connect('127.0.0.1', '9501')) {
    echo 'link error';
    die;
}

fwrite(STDOUT, "请输入");

$msg = trim(fgets(STDIN));

if (!$client->send($msg)) {
    echo '发送失败，错误代码' . $client->errCode;
}

$result = $client->recv();

echo $result;